package com.admin.boot.modules.system.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;


import java.util.Date;

import java.math.BigDecimal;


import java.io.Serializable;
import java.util.List;

/**
 * (SysMenu)实体类
 *
 * @author makejava
 * @since 2024-01-12 14:51:54
 */

@Data
@TableName("sys_menu")
@Accessors(chain = true)
public class SysMenu implements Serializable {


    private static final long serialVersionUID = -43316718241889750L;

    /**
     * 主键
     */
    @TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "主键")
    private String id;

    /**
     * 创建时间
     */
    @ApiModelProperty(value = "创建时间")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /**
     * 更新时间
     */
    @ApiModelProperty(value = "更新时间")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    /**
     * 菜单名称
     */
    @ApiModelProperty(value = "菜单名称")
    private String menuName;

    /**
     * 路径
     */
    @ApiModelProperty(value = "路径")
    private String path;

    /**
     * 组件
     */
    @ApiModelProperty(value = "组件")
    private String component;

    /**
     * 父id
     */
    @ApiModelProperty(value = "父id")
    private String pid;

    /**
     * 排序字段
     */
    @ApiModelProperty(value = "排序字段")
    private BigDecimal sortNo;


    @TableField(exist = false)
    private List<SysMenu> children;


    @TableField(exist = false)
    private boolean hasPermission;

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof SysMenu){
            return this.id.equals(((SysMenu) obj).getId());
        }
        return false;
    }

    @Override
    public int hashCode() {
        return this.id.hashCode();
    }
}

